

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/myblog/img/fluid.png">
  <link rel="icon" href="/myblog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="ZTY">
  <meta name="keywords" content="">
  
    <meta name="description" content="工作随记~">
<meta property="og:type" content="article">
<meta property="og:title" content="WorkNormalRecord">
<meta property="og:url" content="https://zty-f.gitee.io/myblog/2024/03/05/work_record/index.html">
<meta property="og:site_name" content="zty-f">
<meta property="og:description" content="工作随记~">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s3.bmp.ovh/imgs/2024/03/05/6b3f47cf4c03c8cd.jpg">
<meta property="article:published_time" content="2024-03-05T08:22:04.000Z">
<meta property="article:modified_time" content="2024-12-28T02:09:42.875Z">
<meta property="article:author" content="ZTY">
<meta property="article:tag" content="记录">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://s3.bmp.ovh/imgs/2024/03/05/6b3f47cf4c03c8cd.jpg">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>WorkNormalRecord - zty-f</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/myblog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/myblog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/myblog/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3799348_11m20qbqwhmo.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"zty-f.gitee.io","root":"/myblog/","version":"1.9.3","typing":{"enable":true,"typeSpeed":150,"cursorChar":"_","loop":true,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/myblog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/myblog/js/utils.js" ></script>
  <script  src="/myblog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/myblog/">
      <strong>思前想后</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" target="_self" href="javascript:;" role="button"
                 data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                魔盒
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/archives/">
                    <i class="iconfont icon-archive-fill"></i>
                    归档
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/categories/">
                    <i class="iconfont icon-yingyong"></i>
                    分类
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" href="/myblog/tags/">
                    <i class="iconfont icon-tags-fill"></i>
                    标签
                  </a>
                
              </div>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/myblog/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" target="_blank" rel="noopener" href="https://github.com/zty-f">
                <i class="iconfont icon-GitHub"></i>
                
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/myblog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="WorkNormalRecord"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        ZTY
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-03-05 16:22" pubdate>
          2024年3月5日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          4.8k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          41 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">WorkNormalRecord</h1>
            
            
              <div class="markdown-body">
                
                <p>虚心听取建议和意见，多学习，多看看有效的代码以及学习编程和业务理解思想。</p>
<ol>
<li><p>线上环境和测试环境访问通过Switchhost切换再访问。</p>
</li>
<li><p>开发新功能一定要<strong>兼容</strong>之前的版本，注意字段变更和逻辑判断问题。</p>
</li>
<li><p>写代码之前先规划一下大体结构，注意代码的优化，注意细节问题的把握。</p>
</li>
<li><p>注意日志的合理打印，不要都等有问题之后再加日志，注意日志的格式和级别。</p>
</li>
<li><p>对于代码的安全问题要严格进行效验，前后端都需要，不能嫌麻烦就不处理。</p>
</li>
<li><p>redis设置key时要添加统一前缀，比如UserID_1001:对象内容</p>
</li>
<li><p>代码中多处出现的相同的代码提取成方法来进行简化，数字进行常量提取优化</p>
</li>
<li><p>做原来的东西的修改操作时一定要仔细考虑到影响范围，要考虑到是否会影响其他东西</p>
</li>
<li><p>go strcut可以通过  Name int <code>json:&quot;name,string&quot; </code> 来指定该字段使用string类型接收来转换。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs go"><span class="hljs-keyword">type</span> User <span class="hljs-keyword">struct</span> &#123;<br>   Name <span class="hljs-type">int</span>  <span class="hljs-string">`json:&quot;name,string&quot;`</span><br>   Age  <span class="hljs-type">bool</span> <span class="hljs-string">`json:&quot;age,string&quot;`</span><br>&#125;<br>可以将<span class="hljs-type">string</span>类型的json转换为对应的类型<br></code></pre></td></tr></table></figure>
</li>
<li><p>go - redis的setnx和hsetnx是同步的，并且同类型键值存在不会报错，虽然是string和hash两种，但是也不能出现key相同。</p>
</li>
<li><p>先set  a  然后再hset&#x2F;hsetnx a，会报错，先Hset a 然后再set a,会把之前的hash覆盖,如果是setnx则不会报错，也不会修改原hash，不会覆盖。</p>
</li>
<li><p>time.Duration(0)  redis过期时间设置0 为永久</p>
</li>
<li><p>Redis 删除不存在的key不会报错，del  srem都一样</p>
</li>
<li><p>状态码5XX表示服务端错误。</p>
</li>
</ol>
<p>|状态码|含义|<br>|::|::|<br>|500 Internal Server Error|服务器内部错误，服务器处理请求的过程中出现一个错误（内存地址越界、空指针等），导致服务器无法继续处理请求。|<br>|502 Bad Gateway|网关错误，网关请求服务器，在网关设置的超时时间之内服务器中断请求，即没有正常返回数据。|<br>|504 Gateway Timeout|网关超时，网关请求服务器，到了网关设置的超时时间之后服务器仍然没有返回数据。|</p>
<ol start="15">
<li>find . -name “*.go” | xargs cat | wc -l   查询项目代码行数.</li>
<li>ctx.shouldBind既可以接收Get参数也可以接收Post参数，更加灵活.</li>
<li>新服务部署完后需要配置deployment的yaml配置文件</li>
</ol>
<p>配置后才能正常的访问内网环境域名的接口</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">hostAliases:</span><br>        <span class="hljs-bullet">-</span> <span class="hljs-attr">hostnames:</span><br>            <span class="hljs-bullet">-</span> <span class="hljs-string">x.x.x.com</span><br>          <span class="hljs-attr">ip:</span> <span class="hljs-string">x.x.x.x</span><br>        <span class="hljs-bullet">-</span> <span class="hljs-attr">hostnames:</span><br>            <span class="hljs-bullet">-</span> <span class="hljs-string">x.x.x.com</span><br>          <span class="hljs-attr">ip:</span> <span class="hljs-string">x.x.x.x</span><br>        <span class="hljs-bullet">-</span> <span class="hljs-attr">hostnames:</span><br>            <span class="hljs-bullet">-</span> <span class="hljs-string">x.x.x.com</span><br>          <span class="hljs-attr">ip:</span> <span class="hljs-string">x.x.x.x</span><br></code></pre></td></tr></table></figure>

<ol start="18">
<li>MySQL  select…… For update 对于查询的数据加锁，避免其他的事务操作修改数据</li>
</ol>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/moyui/articles/12051588.html">https://www.cnblogs.com/moyui/articles/12051588.html</a></p>
<ol start="19">
<li>查看文件大小命令</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sh"><span class="hljs-built_in">ls</span> -lh<br><span class="hljs-built_in">du</span> -sh<br></code></pre></td></tr></table></figure>

<ol start="20">
<li>gorm的In查询的注意点</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs sql">ids :<span class="hljs-operator">=</span> []<span class="hljs-type">int</span>&#123;<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>&#125;<br>db.Find(<span class="hljs-operator">&amp;</span>users, ids) <span class="hljs-operator">/</span><span class="hljs-operator">/</span> <span class="hljs-keyword">SELECT</span> <span class="hljs-operator">*</span> <span class="hljs-keyword">FROM</span> users <span class="hljs-keyword">WHERE</span> id <span class="hljs-keyword">IN</span> (<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>);<br>使用上述语句进行<span class="hljs-keyword">In</span>查询对应的主键ID数组为空的时候，会查询全部的值。<br>解决办法：<br>使用db.Find(<span class="hljs-operator">&amp;</span>users,&quot;id in (?)&quot;, ids)<br>手动拼接<span class="hljs-keyword">in</span>查询语句，在数组为空的时候就不会查询出数据。<br></code></pre></td></tr></table></figure>

<ol start="21">
<li>gorm数据库查询排序，优先根据a字段降序，再根据b字段降序</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs sql">错误写法： 下面的a后面不指定排序方式会默认采用升序进行排序<br>db.Order(&quot;a,b desc&quot;).Find(<span class="hljs-operator">&amp;</span>users)这个语句等同于db.Order(&quot;a asc,b desc&quot;).Find(<span class="hljs-operator">&amp;</span>users)<br>正确写法：<br>db.Order(&quot;a desc,b desc&quot;).Find(<span class="hljs-operator">&amp;</span>users)<br></code></pre></td></tr></table></figure>

<ol start="22">
<li>系统设计原则</li>
</ol>
<p>系统设计开发过程中遵循的基本原则，包括架构设计、功能实现、代码编写。</p>
<h4 id="简单适用原则"><a href="#简单适用原则" class="headerlink" title="简单适用原则"></a>简单适用原则</h4><p>简单，要求设计简单、理解简单、维护简单，意味着容易学习上手、开发维护成本小、不容易出问题；适用，要求系统应能够通过合适的方式满足业务需求，意味着系统应当面向我们的业务特性量身定制。</p>
<p>简单适用原则，要求设计应当以最简单优雅的方式，满足业务需求。能够用简单的方式解决的问题，就不要用更复杂的方式，不炫技；一些目前预见没有必要的功能，不需要实现，但在设计时应当为后续的实现预留条件，并避免过度设计。</p>
<h4 id="最大共性原则"><a href="#最大共性原则" class="headerlink" title="最大共性原则"></a>最大共性原则</h4><p>最大共性原则，要求在设计过程中，跳出具体的业务功能需求，从更高的视角寻找业务的共性，抽象出业务模型，针对业务模型进行开发， 进而通过业务模型实现功能需求。</p>
<p>优秀的业务模型，能够在后续的持续开发迭代中保证系统的逻辑一致性和可扩展性，降低开发成本并延长系统的使用周期， 避免通过不断拷贝代码、增加逻辑分支而陷入开发的绝望循环。</p>
<ol start="23">
<li><p>项目代码开发规范</p>
<p>【强制】时间相关字段无特别说明MySQL中类型使用 int(11) 无符号 （支持 0-4294967295）,  golang中类型使用int64；</p>
<p>【强制】学生ID字段统一用stuId，数据库字段类型 bigint（20）无符号，golang中类型使用int64；</p>
<p>【强制】和环境（测试、灰度、生产环境）相关配置统一到app的configs中，禁止在代码中硬编码；</p>
<p>【推荐】数据逻辑处理，特别是涉及到多表的逻辑，尽量在biz层处理， 开启事务除外；</p>
<p>【强制】api的Response输出字段统一使用驼峰命名；</p>
<p>【强制】数据库表名、字段全部使用小写，单词间下划线分割；</p>
<p>【强烈推荐】Redis key 统一使用小写，统一增加前缀growth，功能或库表分割使用英文冒号（:），其他分隔符使用下划线（_）, 复杂类型的field命名使用驼峰；</p>
<p>【强烈推荐】日志打印原则：谁报错谁打日志的原则，即：data内报错， 由data打印错误日志，biz层直接调用data产生的错误可不打印日志； 但biz内调用data后数据处理发生的错误应该有biz层自行打印错误日志；</p>
<p>【强烈推荐】打印错误日志时，要把关键参数或数据放到日志中， 不要仅打印error信息；</p>
<p>【强烈推荐】方法或函数要加注释，特殊逻辑要加详细注释甚至文档链接加以说明；</p>
<p>【强烈推荐】data层入参是结构体时，要对必需属性做校验，防止外层调用漏传，进而写脏数据；</p>
<p>【强烈推荐】数据库新增操作：使用结构体进行创建的时候，对于有值的字段采用select区分出来，避免数据库默认值设置错误问题。比如is_deleted默认值为-1，不是字段零值；</p>
<p>【强烈推荐】数据库修改操作：尽量使用map结构映射字段进行更新，使用结构体更新会存在零值更新失败的问题；</p>
<p>【强烈推荐】数据库查询操作：尽量使用Take、Last、First进行查询，使用Find进行查询的时候查询不到不会报错，前面三个会报错record not found；</p>
<p>【强烈推荐】MySQL字段都设置为NOT NULL，并设置默认值；</p>
<p>【强制】ToC接口统一使用POST，不再区分GET和POST，和客户端使用保持统一；</p>
</li>
<li><p>Dockerfile模板</p>
</li>
</ol>
<figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs dockerfile"><span class="hljs-keyword">FROM</span> public-<span class="hljs-keyword">env</span>-mirror-service-registry.cn-beijing.cr.aliyuncs.com/dist/golang:<span class="hljs-number">1.16</span><br><br><span class="hljs-keyword">WORKDIR</span><span class="language-bash"> /tmp/source</span><br><span class="hljs-comment"># 准备工作</span><br><span class="hljs-comment">#RUN export</span><br><span class="hljs-keyword">COPY</span><span class="language-bash"> go.mod .</span><br><span class="hljs-keyword">COPY</span><span class="language-bash"> go.sum .</span><br><span class="hljs-keyword">COPY</span><span class="language-bash"> . .</span><br><br><span class="hljs-comment">#加入git访问权限</span><br><span class="hljs-comment">#COPY .netrc /root/.netrc</span><br><br><span class="hljs-comment"># 编译</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> go <span class="hljs-built_in">env</span> -w GOPRIVATE=xxx.xxx.com</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> go <span class="hljs-built_in">env</span></span><br><span class="hljs-comment">#WORKDIR /tmp/source/cmd/server</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> GOPROXY=<span class="hljs-string">&quot;https://goproxy.cn&quot;</span> GO111MODULE=on go build -o /tmp/source/bin/server .</span><br><span class="hljs-keyword">RUN</span><span class="language-bash"> <span class="hljs-built_in">chmod</span> +x /tmp/source/bin/server</span><br><br><span class="hljs-keyword">WORKDIR</span><span class="language-bash"> /tmp/source</span><br><span class="hljs-comment">#ARG envType=test</span><br><span class="hljs-comment">#COPY configs/config_$&#123;envType&#125;.toml conf/env/env.toml</span><br><span class="hljs-comment"># 执行编译生成的二进制文件</span><br><span class="hljs-keyword">CMD</span><span class="language-bash"> [<span class="hljs-string">&quot;/tmp/source/bin/server&quot;</span>,<span class="hljs-string">&quot;-conf&quot;</span>,<span class="hljs-string">&quot;conf/env/env.toml&quot;</span>]</span><br><span class="hljs-comment"># 暴露端口</span><br><span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">80</span><br></code></pre></td></tr></table></figure>
<ol start="25">
<li><strong>忽略已经加入版本管理的文件</strong></li>
</ol>
<p>如果某些文件已经被纳入了版本管理中，直接修改.gitignore是无效的。需要先把文件从版本管理的索引中删除，然后修改.gitignore文件，然后提交即可。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 第一步：从索引中删除文件</span><br>git <span class="hljs-built_in">rm</span> --cached filename<br><span class="hljs-comment"># 第二部：修改 .gitignore文件，添加忽略规则</span><br><span class="hljs-comment"># 第三步：提交变更</span><br>git commit -m <span class="hljs-string">&#x27;update .gitignore&#x27;</span><br></code></pre></td></tr></table></figure>

<ol start="26">
<li><strong>go替换依赖资源包为本地文件</strong></li>
</ol>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs go">replace codeup.aliyun.com/<span class="hljs-number">61e54</span>b0e0bb300d827e1ae27/backend/golib v1<span class="hljs-number">.0</span><span class="hljs-number">.60</span><span class="hljs-number">-0.20240312093259</span><span class="hljs-number">-7793</span>c839dcce =&gt; /Users/xwx/<span class="hljs-keyword">go</span>/src/golib<br></code></pre></td></tr></table></figure>

<ol start="27">
<li>Gin框架的shouldBind方法针对json格式的参数一次请求只能使用一次，不能多次使用，绑定参数的时候有多次绑定的情况需要额外注意前端传参的格式已经接口的协议是GET还是POST。</li>
</ol>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/davis12/p/16355634.html">https://www.cnblogs.com/davis12/p/16355634.html</a></p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs go"><span class="hljs-comment">// ShouldBind绑定参数时，如果参数类型是form-data/x-www-form-urlencoded时,可以多次使用ShouldBind</span><br><span class="hljs-comment">// 但是如果参数类型是json时，只能使用一次ShouldBind</span><br><br><span class="hljs-comment">// ShouldBindJSON不能使用多次，尽管是针对不同地址空间的结构体,也不能和shouldBind共同使用多次</span><br>	<span class="hljs-comment">//1.单次解析，追求性能使用 ShouldBindJson，因为多次绑定解析会出现EOF</span><br>	<span class="hljs-comment">//2.多次解析，避免报EOF，使用ShouldBindBodyWith</span><br></code></pre></td></tr></table></figure>

<ol start="28">
<li>tree 文件目录  ，这个命令可以获取文件结构</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs sh">xwx@xwxdeMacBook-Pro src % tree <span class="hljs-built_in">test</span>   <br><span class="hljs-built_in">test</span><br>├── algorithm<br>│   └── algorithm_test.go<br>├── base<br>│   ├── base.go<br>│   └── base_test.go<br>├── benchmark<br>│   └── test01<br>│       ├── map_array.go<br>│       └── map_array_test.go<br>├── util<br>│   ├── time_test.go<br>│   ├── util.go<br>│   └── util_test.go<br>├── websocket<br>│   └── main.go<br>└── 完成学习.png<br><br>43 directories, 72 files<br></code></pre></td></tr></table></figure>

<ol start="29">
<li>设置header头的时候不论大小写，在真正进行http&#x2F;https请求的时候，不同的web框架会将header头转换为不同的格式。php fend框架会转换为HTTP_原key全大写，go gin框架会转化为全驼峰。<br><img src="https://s3.bmp.ovh/imgs/2024/03/30/2c99fa7469baa3bc.png" srcset="/myblog/img/loading.gif" lazyload><br><img src="https://s3.bmp.ovh/imgs/2024/03/30/e6b1ca01c7d3a3ed.png" srcset="/myblog/img/loading.gif" lazyload></li>
</ol>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/myblog/categories/%E6%9D%82%E8%AE%B0/" class="category-chain-item">杂记</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/myblog/tags/%E8%AE%B0%E5%BD%95/">#记录</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>WorkNormalRecord</div>
      <div>https://zty-f.gitee.io/myblog/2024/03/05/work_record/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>ZTY</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年3月5日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2024年12月28日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/myblog/2024/03/25/KAFKA%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86%E8%A6%81%E7%82%B9/" title="KAFKA基本原理要点">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">KAFKA基本原理要点</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/myblog/2024/02/01/Certbot%20ssl%E5%AE%89%E8%A3%85/" title="Certbot配置免费ssl证书">
                        <span class="hidden-mobile">Certbot配置免费ssl证书</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"wLiqWYFHh2NEnXVcULmB4KWQ-gzGzoHsz","appKey":"GSfJMcM0GcCzp1HDNXJfd9Bt","path":"window.location.pathname","placeholder":"欢迎大家积极评论~  支持Markdown格式~","avatar":"wavatar","meta":["nick","mail","link"],"requiredFields":["nick","mail"],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":true,"serverURLs":"https://wliqwyfh.lc-cn-n1-shared.com","emojiCDN":null,"emojiMaps":null,"enableQQ":true},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
      <div class="col-lg-7 mx-auto nopadding-x-md">
        <div class="container custom mx-auto">
          <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"> <script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js"></script> <meting-js server="netease"  type="playlist"  id="7708362143" fixed="true"  mini="true" order="list" loop="all" preload="auto" list-folded="true" autoplay="true" theme="red"> </meting-js>
        </div>
      </div>
    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://github.com/zty-f" target="_blank" rel="nofollow noopener"><span>Copyright &copy;</span></a> <a href="http://www.zty-f.fun/" target="_blank" rel="nofollow noopener"><span>zty-f</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
    <!-- 备案信息 ICP for China -->
    <div class="beian">
  <span>
    <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
      蜀ICP备2022002077号-1
    </a>
  </span>
  
</div>

  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/myblog/js/events.js" ></script>
<script  src="/myblog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/myblog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/myblog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/myblog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
